(function () {
    var option = {
        color: ['#E5F2FF ', '#23F9EC', '#2B99FF', '#F8B136'],
        tooltip: {
            trigger: 'item',
            // formatter: "{a} <br/>{b}: {c} ({d}%)"
            formatter: "{c}"
        },
        legend: {
            data: [],
            textStyle:{
                color: 'rgba(255,255,255,0.8)'
            }
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: [],
            axisLabel: {
                textStyle: {
                    color: '#838687',
                    fontSize: '10'
                },
                // interval: 0,
                rotate: 40
            }
        },
        yAxis: {
            inverse: false,
            axisLabel: {
                textStyle: {
                    color: '#838687',
                    fontSize: '10'
                },
                interval: 0,
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: '#585858'
                }
            },
        },
        series: []
    };
    
    const date = new Date()
    $.ajax({
        url: info.base_url + '/ccp/MonitoringCenterController/getTotal',
        type: 'post',
        dateType: 'json',
        data: {
            time: date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate(),
            token: info.token
        },
        success: function (res) {
            option.xAxis.data = res.bean.loginNum.map(function (ele, i) {
                return ele.time.replace('2018-', '')
            })
            for (var i in res.bean) {
                let name
                if (i === 'consume') {
                    name = '消费'
                } else if (i === 'loginNum') {
                    name = '登陆'

                } else if (i === 'rechargeNum') {
                    name = '充值'
                } else if (i === 'registeredNum') {
                    name = '注册'
                }
                option.legend.data.push(name)
                option.series.push({
                    data: res.bean[i].map(function (ele) {
                        return ele.count
                    }),
                    type: 'line',
                    name: name
                })
            }
            echarts.init(document.getElementById('serviceTimes')).setOption(option)
            
        }
    })
})()
